POV-Ray : Newsgroups : povray.advanced-users : Object Oriented POV code : Re: Object Oriented POV code Server Time
29 Jul 2024 14:22:52 EDT (-0400)
  Re: Object Oriented POV code  
From: Dan P
Date: 20 Feb 2004 10:36:22
Message: <40362976$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:4035e6de@news.povray.org...
> Dan P <dan### [at] yahoocom> wrote:
> > To create the object dynamically without the new keyword, the
interpreter
> > would need to look up whether what proceeds it is a Class or something
that
> > the user already defined. That would not effect small scenes, but in
scenes
> > with hundreds of thousands of objects, it would show in the parse time.
By
> > using new, the interpreter /knows/ that what follows it is a class.
>
>   Believe it or not, there are faster ways of searching than linear
search.

Yep, I know; I spent an entire summer building AVL trees and heaps. But it
is /still time/ and, in a loop, that time adds up.

>   Even if you have 4000 millions of names, you can find a specific one
> by doing at most 32 comparisons.
>   In the same way, adding a new name to the set of existing names requires
> at most 32 comparisons and other operations.

32 comparisons for /one lookup/. Multiply that by, say, 100,000 lookups for
fur.

>   Besides, what does it help to tell the interpreter that "what follows is
> a type"? By that you can at best just cut the amount of items to search
> to half (to 2000 millions in the example above).

In a loop, that makes a difference.

> > I think it would be a really good idea to make everything an instance of
a
> > class.
>
>   There's a reason why in Java everything is not an instance of a class.

I think everything should have been. It was just a programmer's decision to
do that, probably because of their C/C++ experience. However, it is
certainly true that if all primitives were represented by a class, it would
take more memory, and even though it might only take a slight bit more
memory, with hundreds of thousands of instances that can show as well so it
might be a good idea to use primitives in a ray-tracing context anyway.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.